<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="angular.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
	<table>
		<tr>
			<th>数量</th>
			<th>价格</th>
			<th>总价</th>
		</tr>
		<tr ng-repeat="item in data">
		    <td><input ng-click="dian()" type="checkbox" ng-checked="bol"></td>
			<td>{{item.num}}</td>
			<td>{{item.price}}</td>
			<td>{{item.num/1*item.price/1}}</td>
		</tr>
		<tr>
			<td><input type="checkbox" ng-checked="allbol"></td>
			<td>{{total()}}</td>
		</tr>
	</table>
</body>
<script>
	angular.module('myApp',[])
    
     .controller("myCtrl",["$scope","$rootScope","$http",function($scope,$rootScope,$http){
          $http.get("data.json").then(function(data){
          	   console.log(data);
          	   $scope.data = data.data;
          });
          $scope.bol= true;
          $scope.allbol = true;
          $scope.total = function(){
          	  var index = 0;	  
	          angular.forEach($scope.data,function(e){
	             index = index + e.price*e.num;
	          });
          	  return index;
          }
          var ind = 0;
          $scope.dian = function(){
          	 ind++;
          	 console.log(ind);
          	 if(ind/2==0){
          	 	console.log(1);
          	 	$scope.allbol = true;
          	 }else{
          	 	$scope.allbol = false;
          	 }
          }
          $scope.$watch("data",function(newvalue,oldvalue){
          	    
          })
     }])


</script>
</html>